<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!doctype html>
<html class="no-js">
<head>
<title>完善资料</title>
<%@ include file="../../mobilehead_inc.jsp"%>
<script src="/mobile/js/infinitedropdown.min.js"></script>
<style>
.am-direction-nav {
	display: none;
}

#submitButton {
	float: right;
	list-style-type: none;
	margin-top: 5px
}

#myform {
	margin-left: 10px;
	margin-right: 10px;
}

#myform table tbody tr td input {
	font-size: 15px
}

#myform table tbody tr td {
	color: gray
}

#inTable tr td {
	color: gray
}
</style>
<script>	
/* 	$(document).on('pageinit', function () {
		 document.getElementById('hiddenbut').style.display = "none";
	    $.ajax({
	        url: '${ctx}${getSchool}',
	        dataType: "json",
	        async: true,
	        success: function (result) {
	        	if(result.obj != null && result.obj.length > 0){
	        		$("#js-selected-info").append("<select  data-am-selected name=\"js-selected\" id=\"js-selected\" > <option selected  value=\"999999\">请选择学校</option> </select>");
	        		var $selected = $('#js-selected');
	        		for(var i=0;i<result.obj.length;i++){
		        		 $selected.append('<option value="' + result.obj[i].depId +'"> ' + result.obj[i].depName + '</option>');
		        	}
	        	}
	        	
	        	
	        },
	        error: function (request, error) {
	        	alert("数据加载出错");
	        }
	        
	    });
	    
	  
	}); */
	
	 
	 function isNull( str ){
			if ( str == "" ) return true;
			var regu = "^[ ]+$";
			var re = new RegExp(regu);
			return re.test(str);
		}
	
	
	function checkSubmit() {
		var phone = $("#phone").val();
		var name = $("#name").val();
		var address = $("#js-selected").find("option:selected").text()+$("#address").val();
		var depId = $("#js-selected").val();
		name = encodeURI(encodeURI(name));
		address = encodeURI(encodeURI(address));
		if (name == null || name == "") {
			$("#alertmsg").empty();
			$("#alertmsg")
					.append(
							"<div class='am-alert am-alert-success' data-am-alert><button type='button' class='am-close'>&times;</button><p>请填写姓名！</p></div>");
			document.myform.name.focus();
			return false;
		}
	/* 	if (depId == 999999) {
			$("#alertmsg").empty();
			$("#alertmsg")
					.append(
							"<div class='am-alert am-alert-success' data-am-alert><button type='button' class='am-close'>&times;</button><p>请选择你的学校！</p></div>");
			document.myform.phone.focus();
			return false;
		} */
		
		if (phone == null || phone == "") {
			$("#alertmsg").empty();
			$("#alertmsg")
					.append(
							"<div class='am-alert am-alert-success' data-am-alert><button type='button' class='am-close'>&times;</button><p>请填写手机号！</p></div>");
			document.myform.js-selected.focus();
			return false;
		}
		
		if (address == null || address == "" || isNull(address)) {
			$("#alertmsg").empty();
			$("#alertmsg")
					.append(
							"<div class='am-alert am-alert-success' data-am-alert><button type='button' class='am-close'>&times;</button><p>请输入你的收货地址！</p></div>");
			document.myform.address.focus();
			return false;
		}

		

		var url = "${ctx}/mobile/saveAddress?address="+address+"&name="+name+"&phone="+phone;
		$.getJSON(url, function(json) {
			if (json.success == 0) {

				$("#alertmsg").empty();
				document.getElementById("sub_target").click();
				setTimeout(function (){
					window.location.href = '${ctx}/mobile/main';
				},3000);
			} else {
				$("#alertmsg").empty();
				$("#alertmsg").append(
						"<div class='am-alert am-alert-success' > " + json.msg + " </div>");
			}
		});
		return true;
	}
</script>
<style>
.am-direction-nav {
	display: none;
}
</style>
</head>
<body style="background:#FFFFCC">
	<!-- 上部 -->
	<header data-am-widget="header" class="am-header am-header-default joan-head" style="background:#9999FF">


		<h1 class="am-header-title">
			<a href="#title-link" class=""> 完善资料 </a>
		</h1>


	</header>



	<!-- 中间 -->
	<br/>
	<div class="am-g">
  <div class=" col-md-8 col-sm-centered">
  <div id="alertmsg"></div>
  
    <form class="am-form" id="myform" method="POST" name="myform" onsubmit="return checkSubmit()">
      <fieldset class="am-form-set">
      	 <input type="text"  id="name" name="name" placeholder="请输入您输入姓名"><br/>     
        <input type="text" maxlength="11" onkeyup="value=value.replace(/[^1234567890]+/g,'')" id="phone" name="phone" placeholder="请输入您的手机号"><br/>     
		
			<div  id="js-selected-info"></div> <br/>
			<textarea  id="address"  name="address"  placeholder="请输入你的地址"></textarea><br/>
				</fieldset>
				
				
       <a href="${ctx}/mobile/main" target="_self" ><input type="submit" id="sub_butt" name="sub_butt" data-ajax="false"  class="am-btn am-btn-success am-btn-block"/></a>
    </form>
  </div>
</div>

<center><div ><font  size="6"  color="red">此功能还在完善中</font></div></center>
<!-- 提示卡 -->
<!-- <div id="hiddenbut"><button
  type="button" id="sub_target"
  class="am-btn am-btn-primary"
  data-am-modal="{target: '#my-alert'}">
</button></div>
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
  <div class="am-modal-dialog">
    <div class="am-modal-bd">
      提交成功,3秒后自动返回首页！
    </div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">确定</span>
    </div>
  </div>
</div> -->

	<!--底部 -->
	<!--  ${bottom} -->


</body>
</html>
